#!/bin/sh

# Slackware build script for ttf-sil-gentium
# Written by Kyle Guinn

# Modified by the SlackBuilds.org project

set -e

PRGNAM=ttf-sil-gentium
VERSION=1.02
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
CWD=`pwd`
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP 
rm -rf $PRGNAM-$VERSION

# First, if the source was pulled with wget, then it might not get named
# correctly - let's fix that
if [ -e "$CWD/render_download.php?site_id=nrsi&format=file&media_id=Gentium_102_L_tar&filename=%2Fttf-sil-gentium_1.0.2.tar.gz" ]; then
  mv "$CWD/render_download.php?site_id=nrsi&format=file&media_id=Gentium_102_L_tar&filename=%2Fttf-sil-gentium_1.0.2.tar.gz" \
    "$CWD/-ttf-sil-gentium_1.0.2.tar.gz"
fi

# Watch out for the name of this tarball - the leading '-' might cause problems
# To remove it, try `rm /path/to/-ttf-sil-gentium_1.0.2.tar.gz`
# or rm -- -ttf-sil-gentium_1.0.2.tar.gz
tar -xzvf $CWD/\-ttf-sil-gentium_1.0.2.tar.gz || exit 1
cd $PRGNAM-$VERSION || exit 1

chown -R root:root .
chmod -R u+w,go+r-w,a-s .

mkdir -p $PKG/usr/share/fonts
cp -a *.ttf $PKG/usr/share/fonts

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a FONTLOG GENTIUM-FAQ OFL* README $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -p -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
